# Julia Schule-Cloos Copyright (c) 2021
FROM rocker/tidyverse:4.0.3

# Path to the replaction files in the docker container
ENV REPLICATION_PATH=/home/rstudio/afd_potentials_replication

# Set user, workdir, disable authentication and give user root privileges
USER root
WORKDIR /home/rstudio
ENV DISABLE_AUTH=true
ENV ROOT=true

# # Install system dependencies for R 
RUN apt-get update && apt-get install -y \
 libudunits2-dev \
 libgdal-dev \
 libgeos-dev \
 libproj-dev


ENV MRAN_BUILD_DATE=2021-04-16

# Install R package dependencies
RUN install2.r -r https://cran.microsoft.com/snapshot/${MRAN_BUILD_DATE} \
	--error \
	pacman \
	bookdown \
	tidyverse \
	knitr \
	kableExtra \
	sf \
	RColorBrewer \
	modelsummary \
	tictoc \
	spdep \
	gridExtra \
	colorspace \
	scales \
	broom \
	jcolors \
	lubridate \
	spatialreg \
	showtext \
	furrr


# copy files
COPY ./data $REPLICATION_PATH/data/
COPY ./SCHULTE-CLOOS_Potentials_AfD_REPLICATION.Rmd $REPLICATION_PATH/SCHULTE-CLOOS_Potentials_AfD_REPLICATION.Rmd
COPY ./replication_references.bib $REPLICATION_PATH/replication_references.bib

# Change ownership of replication files to 'rstudio' user to allow Knitting the file
RUN chown -R rstudio $REPLICATION_PATH && \
    chgrp -R rstudio $REPLICATION_PATH